package com.atguigu.algorithm;

public class HorseMode {
    //方法,给定目的地m,n,步数k
    //arr为棋盘大小
    public static int f(int m,int n,int k,int[][] arr){
        return process(arr,m,n,k);
    }
    //递归的方法
    public static int process(int[][] arr,int m,int n,int k){
        //边界条件
        if(m>=arr[0].length || m<0 || n>=arr.length || n<0){
            return 0;
        }
        if(k==0){ //此时无法再走动了
            return (m==0 && n==0) ? 1: 0;
        }
        return process(arr,m-1,n+2,k-1)+process(arr,m-1,n-2,k-1)+
                process(arr,m+1,n+2,k-1)+process(arr,m+1,n-2,k-1)+
                process(arr,m-2,n+1,k-1)+process(arr,m-2,n-1,k-1)+
                process(arr,m+2,n+1,k-1)+process(arr,m+2,n-1,k-1);
    }

}
